from datetime import datetime
from typing import Union, Any, Optional, List

from pydantic import BaseModel, EmailStr, Field
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DateTime
from sqlalchemy.orm import relationship
#from sqlalchemy.sql import func
from sqlalchemy import func
from sqlalchemy.schema import Sequence

from app.common.database import Base


class TableBasic(Base):
    __abstract__ = True

class TableBase2(Base):
    __abstract__ = True

    create_time = Column(DateTime, default=func.now(), comment='创建时间')
    update_time = Column(DateTime, default=func.now(), onupdate=func.now(),  comment='更新时间')
    #create_time = Column(DateTime, server_default=func.now(), comment='创建时间')
    #update_time = Column(DateTime, server_default=func.now(), onupdate=func.now(),  comment='更新时间')
    

class TableBase(Base):
    __abstract__ = True
    
    create_by = Column(String(32), comment='创建人', nullable=True)
    update_by = Column(String(32), comment='更新人', nullable=True)
    create_time = Column(DateTime, server_default=func.now(), comment='创建时间')
    update_time = Column(DateTime, server_default=func.now(), onupdate=func.now(),  comment='更新时间')
    status = Column(Integer, comment='状态')

    '''
    def to_dict(self):
        model_dict = dict(self.__dict__)
        del model_dict['_sa_instance_state']
        return model_dict
 
    Base.to_dict = to_dict

    @staticmethod
    def to_json(all_vendors):
        v = [ven.dobule_to_dict() for ven in all_vendors]
        return v
    '''

